package se.ytterman.jpcap.tests;

import se.ytterman.jpcap.jni.*;

public class BasicTest {

    public static void main(String argv[]) {
        // Check if we have a proper number of arguments...
        if(argv.length == 0) {
            System.out.println("No testcase name givven, terminating");
        }
        else {
            // Define different tests...
            if(argv[0].compareTo("dummy") == 0) {
            // Test 0, dummy test
            System.out.println("Dummy test...");

            } else if(argv[0].compareTo("list_interfaces") == 0) {
                // Test 1, list interfaces
                System.out.println("Listing insterfaces...");

                // Create Pcap interface factory
                PcapInterfaceFactory factory = new PcapInterfaceFactory();

                try {
                    // Fetch interface array
                    PcapInterface interfaces[] = factory.getInterfaceArray();

                    // Print interfaces...
                    for(int i = 0; i < interfaces.length; i++) {
                        System.out.println(interfaces[i]);
                    }
                }
                catch(PcapInterfaceFactoryException pife) {
                    System.err.println("PcapInterfaceFactoryException:" + pife.getMessage());
                }
                catch(Throwable tb) {
                    System.err.println("Throwable:" + tb.getMessage());
                }
            }
        }
    }

    private static void printProperties() {
	// Fetch JVM properties
	String property = System.getProperty("java.library.path");

	// Print to STDOUT
	System.out.println(property);
    }
}
